import request from '@/utils/request'

export function getFileById(id) {
  return request({
    url: '/file/fileBase/' + id,
    method: 'get'
  })
}

// 删除文件
export function delFile(id) {
  return request({
    url: '/file/fileBase/' + id,
    method: 'delete'
  })
}

export function getVarParam() {
  return request({
    url: '/file/fileBase/getVarParam',
    method: 'get'
  })
}

// 根据项目 基金等ID查出对应的文件
export function findListByBusinessId(query) {
  return request({
    url: '/file/fileBase/findListByBusinessId',
    method: 'get',
    params: query
  })
}

// 彻底删除
export function permanentlyDelete(idList) {
  return request({
    url: '/file/fileBase/permanentlyDelete/' + idList,
    method: 'delete'
  })
}

export function createFileByProperty(fileBase) {
  return request({
    url: '/file/fileBase/createFileByProperty',
    method: 'post',
    data: fileBase
  })
}

// 计算阅读时间
export function calculateReadingTime(fileId) {
  if (fileId === undefined || fileId === null || fileId === '') {
    fileId = new Date().getTime()
  }
  return request({
    url: '/onlinePreview/calculateReadingTime/' + fileId,
    method: 'get'
  })
}

// 根据文件id修改fileTag
export function addTagToFile(data) {
  return request({
    url: '/file/fileBase/addTagToFile',
    method: 'post',
    data: data
  })
}

// 根据业务Id获取业务对象
export function getBusById(busId) {
  return request({
    url: '/file/fileBase/getBusById/' + busId,
    method: 'get'
  })
}

// 审核该文件中的错误异常数据
export function docReview(id, token) {
  return request({
    url: '/file/fileBase/doc/documentReview/' + id + '/' + token,
    method: 'get'
  })
}

// 根据文档审核返回的openId获取审核结果
export function getDocReviewResult(openId) {
  return request({
    url: '/file/fileBase/doc/getDocumentReviewResult/' + openId,
    method: 'get'
  })
}

// 根据附件ID获取审核结果
export function getFileExamineRecord(fileId) {
  return request({
    url: '/file/fileBase/doc/getFileExamineRecordByFileBase/' + fileId,
    method: 'get'
  })
}

// 合并文件
export function fileBaseMerging(data) {
  return request({
    url: '/file/fileBase/fileBaseMerging',
    method: 'post',
    data: data
  })
}

// 修改表单时, fileTable获取哪些附件需要必填
export function getCheckRequired(dataType, dataId) {
  if (dataType === undefined || dataType === null || dataType === '') {
    dataType = '-1'
  }
  if (dataId === undefined || dataId === null || dataId === '') {
    dataId = '-1'
  }
  return request({
    url: '/file/fileBase/getCheckRequired/' + dataType + '/' + dataId,
    method: 'get'
  })
}
